<?php
/*
 * Template Name: Matching Page Template
 * Description: List links to all a persons friends
 *
 * @ Twyne
 */
 get_header();?>
		
		<div id="primary">
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js "></script>
		<script src="<?php bloginfo('stylesheet_directory'); ?>/javascript/groupselect.js"></script> 	
			<div id="content" role="main">
				
				<header class="entry-header">
					<h1 class="entry-title">Compatibility Matching</h1>
				</header><!-- .entry-header -->
				
				<div id = "match">
				<?php
					global $wpdb;
					
					$userid = $current_user->ID;
							$count=$wpdb->get_var($wpdb->prepare(
                                            "
                                                SELECT count(*)
                                                FROM wp_twyne_matching 
                                                WHERE user_id = $userid
                                            "));
						if($count >= '1'){
						
				?>
				<h4>Select one of your groups to find </br> your Roommate Matches or </br> Edit your Questionaire Answers</h4> 
				<form name="matchMain">
					<div id="find_groups">
					<?php $userid = $current_user->ID;
						
						print "<select name='groups' onChange=return_Group('$userid');>"
						
					?>		
								<?php
								global $wpdb;
                                echo "\n";
								//populate users group dropdown
								
                                $groups=$wpdb->get_results($wpdb->prepare(
                                            "
                                                SELECT distinct name,wp_bp_groups.id
                                                FROM wp_bp_groups_members,wp_bp_groups 
                                                WHERE user_id = $userid and wp_bp_groups_members.group_id = wp_bp_groups.id
												ORDER BY name
                                            "));
									if(empty($groups)){
										print "<option selected='selected'> No Groups Found</option>";
									}else{
										print"<option selected='selected'>My Groups</option>";	
										foreach ($groups as $value) {
											echo "<option value={$value->id}>{$value->name}</option>";
										};
									}
                                ?>
								
						</select>
							<?php print "<input type='button' value = 'Edit Answers' class = 'editMatch' onClick = editMatch($userid);>" ?>
							<?php print "<input type='Submit' value = 'Delete Matching' class = 'deleteMatch' onClick = deleteMatch($userid);>" ?>
					</div><!--choose_group -->
				</form>
			<p id = "results"></p>
<?php }else{ ?>

<?php //Shows Matching Questionaire
?>

<div id="matchinglist">	
	<p id = "demo">
	For each of the following characteristics please </br>
	select the value [1-5] that best describes you.	 </br>
	( 1 = not really, 5 = very much)
	</p>
<form name = "matchingForm">	
	<p><u>Co-ED Roommates</u></p>
    <div class="question1">
        <input type="radio" name="q1" id="q1_button_1" value = "1"/>
		<label for="q1_button_1">Yes</label>
    </div>
    <div class="question1">
        <input type="radio" name="q1" id="q1_button_2" checked="checked" value = "0"/>
		<label for="q1_button_2">No</label>
    </div>
	</br>
	</br>
	<p><u>Cleanliness</u></p>
    <div class="question2">
        <input type="radio" name="q2" id="q2_button_1" value = "1"/>
		<label for="q2_button_1">1</label>
    </div>
    <div class="question2">
        <input type="radio" name="q2" id="q2_button_2" value = "2"/>
		<label for="q2_button_2">2</label>
    </div>
    <div class="question2">
        <input type="radio" name="q2" id="q2_button_3" checked="checked" value = "3"/>
		<label for="q2_button_3">3</label>
    </div>
	<div class="question2">
        <input type="radio" name="q2" id="q2_button_4" value = "4"/>
		<label for="q2_button_4">4</label>
    </div>
	<div class="question2">
        <input type="radio" name="q2" id="q2_button_5" value = "5"/>
		<label for="q2_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>Quietness</u></p>
    <div class="question3">
        <input type="radio" name="q3" id="q3_button_1" value = "1"/>
		<label for="q3_button_1">1</label>
    </div>
    <div class="question3">
        <input type="radio" name="q3" id="q3_button_2" value = "2"/>
		<label for="q3_button_2">2</label>
    </div>
    <div class="question3">
        <input type="radio" name="q3" id="q3_button_3" checked="checked" value = "3"/>
		<label for="q3_button_3">3</label>
    </div>
	<div class="question3">
        <input type="radio" name="q3" id="q3_button_4" value = "4"/>
		<label for="q3_button_4">4</label>
    </div>
	<div class="question3">
        <input type="radio" name="q3" id="q3_button_5" value = "5"/>
		<label for="q3_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Attend Parties</u></p>
    <div class="question4">
        <input type="radio" name="q4" id="q4_button_1" value = "1"/>
		<label for="q4_button_1">1</label>
    </div>
    <div class="question4">
        <input type="radio" name="q4" id="q4_button_2" value = "2"/>
		<label for="q4_button_2">2</label>
    </div>
    <div class="question4">
        <input type="radio" name="q4" id="q4_button_3" checked="checked" value = "3"/>
		<label for="q4_button_3">3</label>
    </div>
	<div class="question4">
        <input type="radio" name="q4" id="q4_button_4" value = "4"/>
		<label for="q4_button_4">4</label>
    </div>
	<div class="question4">
        <input type="radio" name="q4" id="q4_button_5" value = "5"/>
		<label for="q4_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Host Parties</u></p>
    <div class="question5">
        <input type="radio" name="q5" id="q5_button_1" value = "1"/>
		<label for="q5_button_1">1</label>
    </div>
    <div class="question5">
        <input type="radio" name="q5" id="q5_button_2" value = "2"/>
		<label for="q5_button_2">2</label>
    </div>
    <div class="question5">
        <input type="radio" name="q5" id="q5_button_3" checked="checked" value = "3"/>
		<label for="q5_button_3">3</label>
    </div>
	<div class="question5">
        <input type="radio" name="q5" id="q5_button_4" value = "4"/>
		<label for="q5_button_4">4</label>
    </div>
	<div class="question5">
        <input type="radio" name="q5" id="q5_button_5" value = "5"/>
		<label for="q5_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you have friends/family over?</u></p>
    <div class="question6">
        <input type="radio" name="q6" id="q6_button_1" value = "1"/>
		<label for="q6_button_1">1</label>
    </div>
    <div class="question6">
        <input type="radio" name="q6" id="q6_button_2" value = "2"/>
		<label for="q6_button_2">2</label>
    </div>
    <div class="question6">
        <input type="radio" name="q6" id="q6_button_3" checked="checked" value = "3"/>
		<label for="q6_button_3">3</label>
    </div>
	<div class="question6">
        <input type="radio" name="q6" id="q6_button_4" value = "4"/>
		<label for="q6_button_4">4</label>
    </div>
	<div class="question6">
        <input type="radio" name="q6" id="q6_button_5" value = "5"/>
		<label for="q6_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Watch TV?</u></p>
    <div class="question7">
        <input type="radio" name="q7" id="q7_button_1" value = "1" />
		<label for="q7_button_1">1</label>
    </div>
    <div class="question7">
        <input type="radio" name="q7" id="q7_button_2" value = "2"/>
		<label for="q7_button_2">2</label>
    </div>
    <div class="question7">
        <input type="radio" name="q7" id="q7_button_3" checked="checked" value = "3"/>
		<label for="q7_button_3">3</label>
    </div>
	<div class="question7">
        <input type="radio" name="q7" id="q7_button_4" value = "4"/>
		<label for="q7_button_4">4</label>
    </div>
	<div class="question7">
        <input type="radio" name="q7" id="q7_button_5" value = "5"/>
		<label for="q7_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you play Video Games?</u></p>
    <div class="question8">
        <input type="radio" name="q8" id="q8_button_1" value = "1"/>
		<label for="q8_button_1">1</label>
    </div>
    <div class="question8">
        <input type="radio" name="q8" id="q8_button_2" value = "2"/>
		<label for="q8_button_2">2</label>
    </div>
    <div class="question8">
        <input type="radio" name="q8" id="q8_button_3" checked="checked" value = "3"/>
		<label for="q8_button_3">3</label>
    </div>
	<div class="question8">
        <input type="radio" name="q8" id="q8_button_4" value = "4"/>
		<label for="q8_button_4">4</label>
    </div>
	<div class="question8">
        <input type="radio" name="q8" id="q8_button_5" value = "5"/>
		<label for="q8_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Listen to Music?</u></p>
    <div class="question9">
        <input type="radio" name="q9" id="q9_button_1" value = "1"/>
		<label for="q9_button_1">1</label>
    </div>
    <div class="question9">
        <input type="radio" name="q9" id="q9_button_2" value = "2"/>
		<label for="q9_button_2">2</label>
    </div>
    <div class="question9">
        <input type="radio" name="q9" id="q9_button_3" checked="checked" value = "3"/>
		<label for="q9_button_3">3</label>
    </div>
	<div class="question9">
        <input type="radio" name="q9" id="q9_button_4" value = "4"/>
		<label for="q9_button_4">4</label>
    </div>
	<div class="question9">
        <input type="radio" name="q9" id="q9_button_5" value = "5"/>
		<label for="q9_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Drink?</u></p>
    <div class="question10">
        <input type="radio" name="q10" id="q10_button_1" value = "1"/>
		<label for="q10_button_1">1</label>
    </div>
    <div class="question10">
        <input type="radio" name="q10" id="q10_button_2" value = "2"/>
		<label for="q10_button_2">2</label>
    </div>
    <div class="question10">
        <input type="radio" name="q10" id="q10_button_3" checked="checked" value = "3"/>
		<label for="q10_button_3">3</label>
    </div>
	<div class="question10">
        <input type="radio" name="q10" id="q10_button_4" value = "4"/>
		<label for="q10_button_4">4</label>
    </div>
	<div class="question10">
        <input type="radio" name="q10" id="q10_button_5" value = "5"/>
		<label for="q10_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Smoke?</u></p>
    <div class="question11">
        <input type="radio" name="q11" id="q11_button_1" value = "1"/>
		<label for="q11_button_1">1</label>
    </div>
    <div class="question11">
        <input type="radio" name="q11" id="q11_button_2" value = "2"/>
		<label for="q11_button_2">2</label>
    </div>
    <div class="question11">
        <input type="radio" name="q11" id="q11_button_3" checked="checked" value = "3"/>
		<label for="q11_button_3">3</label>
    </div>
	<div class="question11">
        <input type="radio" name="q11" id="q11_button_4" value = "4"/>
		<label for="q11_button_4">4</label>
    </div>
	<div class="question11">
        <input type="radio" name="q11" id="q11_button_5" value = "5"/>
		<label for="q11_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Go Out?</u></p>
    <div class="question12">
        <input type="radio" name="q12" id="q12_button_1" value = "1"/>
		<label for="q12_button_1">1</label>
    </div>
    <div class="question12">
        <input type="radio" name="q12" id="q12_button_2" value = "2"/>
		<label for="q12_button_2">2</label>
    </div>
    <div class="question12">
        <input type="radio" name="q12" id="q12_button_3" checked="checked" value = "3"/>
		<label for="q12_button_3">3</label>
    </div>
	<div class="question12">
        <input type="radio" name="q12" id="q12_button_4" value = "4"/>
		<label for="q12_button_4">4</label>
    </div>
	<div class="question12">
        <input type="radio" name="q12" id="q12_button_5" value = "5"/>
		<label for="q12_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you go to Bed Late?</u></p>
    <div class="question13">
        <input type="radio" name="q13" id="q13_button_1" value = "1"/>
		<label for="q13_button_1">1</label>
    </div>
    <div class="question13">
        <input type="radio" name="q13" id="q13_button_2" value = "2"/>
		<label for="q13_button_2">2</label>
    </div>
    <div class="question13">
        <input type="radio" name="q13" id="q13_button_3" checked="checked" value = "3"/>
		<label for="q13_button_3">3</label>
    </div>
	<div class="question13">
        <input type="radio" name="q13" id="q13_button_4" value = "4"/>
		<label for="q13_button_4">4</label>
    </div>
	<div class="question13">
        <input type="radio" name="q13" id="q13_button_5" value = "5"/>
		<label for="q13_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Sleep In?</u></p>
    <div class="question14">
        <input type="radio" name="q14" id="q14_button_1" value = "1"/>
		<label for="q14_button_1">1</label>
    </div>
    <div class="question14">
        <input type="radio" name="q14" id="q14_button_2" value = "2"/>
		<label for="q14_button_2">2</label>
    </div>
    <div class="question14">
        <input type="radio" name="q14" id="q14_button_3" checked="checked" value = "3"/>
		<label for="q14_button_3">3</label>
    </div>
	<div class="question14">
        <input type="radio" name="q14" id="q14_button_4" value = "4"/>
		<label for="q14_button_4">4</label>
    </div>
	<div class="question14">
        <input type="radio" name="q14" id="q14_button_5" value = "5"/>
		<label for="q14_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How much time do you Spend in your room?</u></p>
    <div class="question15">
        <input type="radio" name="q15" id="q15_button_1" value = "1"/>
		<label for="q15_button_1">1</label>
    </div>
    <div class="question15">
        <input type="radio" name="q15" id="q15_button_2" value = "2"/>
		<label for="q15_button_2">2</label>
    </div>
    <div class="question15">
        <input type="radio" name="q15" id="q15_button_3" checked="checked" value = "3"/>
		<label for="q15_button_3">3</label>
    </div>
	<div class="question15">
        <input type="radio" name="q15" id="q15_button_4" value = "4"/>
		<label for="q15_button_4">4</label>
    </div>
	<div class="question15">
        <input type="radio" name="q15" id="q15_button_5" value = "5"/>
		<label for="q15_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Cook?</u></p>
    <div class="question16">
        <input type="radio" name="q16" id="q16_button_1" value = "1"/>
		<label for="q16_button_1">1</label>
    </div>
    <div class="question16">
        <input type="radio" name="q16" id="q16_button_2" value = "2"/>
		<label for="q16_button_2">2</label>
    </div>
    <div class="question16">
        <input type="radio" name="q16" id="q16_button_3" checked="checked" value = "3"/>
		<label for="q16_button_3">3</label>
    </div>
	<div class="question16">
        <input type="radio" name="q16" id="q16_button_4" value = "4"/>
		<label for="q16_button_4">4</label>
    </div>
	<div class="question16">
        <input type="radio" name="q16" id="q16_button_5" value = "5"/>
		<label for="q16_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Eat Out?</u></p>
    <div class="question17">
        <input type="radio" name="q17" id="q17_button_1" value = "1"/>
		<label for="q17_button_1">1</label>
    </div>
    <div class="question17">
        <input type="radio" name="q17" id="q17_button_2" value = "2"/>
		<label for="q17_button_2">2</label>
    </div>
    <div class="question17">
        <input type="radio" name="q17" id="q17_button_3" checked="checked" value = "3"/>
		<label for="q17_button_3">3</label>
    </div>
	<div class="question17">
        <input type="radio" name="q17" id="q17_button_4" value = "4"/>
		<label for="q4_button_17">4</label>
    </div>
	<div class="question17">
        <input type="radio" name="q17" id="q17_button_5" value = "5"/>
		<label for="q17_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Work at Home?</u></p>
    <div class="question18">
        <input type="radio" name="q18" id="q18_button_1" value = "1"/>
		<label for="q18_button_1">1</label>
    </div>
    <div class="question18">
        <input type="radio" name="q18" id="q18_button_2" value = "2"/>
		<label for="q18_button_2">2</label>
    </div>
    <div class="question18">
        <input type="radio" name="q18" id="q18_button_3" checked="checked" value = "3"/>
		<label for="q18_button_3">3</label>
    </div>
	<div class="question18">
        <input type="radio" name="q18" id="q18_button_4" value = "4"/>
		<label for="q18_button_4">4</label>
    </div>
	<div class="question18">
        <input type="radio" name="q18" id="q18_button_5" value = "5"/>
		<label for="q18_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Study?</u></p>
    <div class="question19">
        <input type="radio" name="q19" id="q19_button_1" value = "1"/>
		<label for="q19_button_1">1</label>
    </div>
    <div class="question19">
        <input type="radio" name="q19" id="q19_button_2" value = "2"/>
		<label for="q19_button_2">2</label>
    </div>
    <div class="question19">
        <input type="radio" name="q19" id="q19_button_3" checked="checked" value = "3"/>
		<label for="q19_button_3">3</label>
    </div>
	<div class="question19">
        <input type="radio" name="q19" id="q19_button_4" value = "4"/>
		<label for="q19_button_4">4</label>
    </div>
	<div class="question19">
        <input type="radio" name="q19" id="q19_button_5" value = "5"/>
		<label for="q19_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Travel?</u></p>
    <div class="question20">
        <input type="radio" name="q20" id="q20_button_1" value = "1"/>
		<label for="q20_button_1">1</label>
    </div>
    <div class="question20">
        <input type="radio" name="q20" id="q20_button_2" value = "2"/>
		<label for="q20_button_2">2</label>
    </div>
    <div class="question20">
        <input type="radio" name="q20" id="q20_button_3" checked="checked" value = "3"/>
		<label for="q20_button_3">3</label>
    </div>
	<div class="question20">
        <input type="radio" name="q20" id="q20_button_4" value = "4"/>
		<label for="q20_button_4">4</label>
    </div>
	<div class="question20">
        <input type="radio" name="q20" id="q20_button_5" value = "5"/>
		<label for="q20_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>How often do you Workout</u></p>
    <div class="question21">
        <input type="radio" name="q21" id="q21_button_1" value = "1"/>
		<label for="q21_button_1">1</label>
    </div>
    <div class="question21">
        <input type="radio" name="q21" id="q21_button_2" value = "2"/>
		<label for="q21_button_2">2</label>
    </div>
    <div class="question21">
        <input type="radio" name="q21" id="q21_button_3" checked="checked" value = "3"/>
		<label for="q21_button_3">3</label>
    </div>
	<div class="question21">
        <input type="radio" name="q21" id="q21_button_4" value = "4"/>
		<label for="q21_button_4">4</label>
    </div>
	<div class="question21">
        <input type="radio" name="q21" id="q21_button_5" value = "5"/>
		<label for="q21_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>Organized</u></p>
    <div class="question22">
        <input type="radio" name="q22" id="q22_button_1" value = "1"/>
		<label for="q22_button_1">1</label>
    </div>
    <div class="question22">
        <input type="radio" name="q22" id="q22_button_2" value = "2"/>
		<label for="q22_button_2">2</label>
    </div>
    <div class="question22">
        <input type="radio" name="q22" id="q22_button_3" checked="checked" value = "3"/>
		<label for="q22_button_3">3</label>
    </div>
	<div class="question22">
        <input type="radio" name="q22" id="q22_button_4" value = "4"/>
		<label for="q22_button_4">4</label>
    </div>
	<div class="question22">
        <input type="radio" name="q22" id="q22_button_5" value = "5"/>
		<label for="q22_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>Outgoing</u></p>
    <div class="question23">
        <input type="radio" name="q23" id="q23_button_1" value = "1"/>
		<label for="q23_button_1">1</label>
    </div>
    <div class="question23">
        <input type="radio" name="q23" id="q23_button_2" value = "2"/>
		<label for="q23_button_2">2</label>
    </div>
    <div class="question23">
        <input type="radio" name="q23" id="q23_button_3" checked="checked" value = "3"/>
		<label for="q23_button_3">3</label>
    </div>
	<div class="question23">
        <input type="radio" name="q23" id="q23_button_4" value = "4"/>
		<label for="q23_button_4">4</label>
    </div>
	<div class="question23">
        <input type="radio" name="q23" id="q23_button_5" value = "5"/>
		<label for="q23_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>Logical</u></p>
    <div class="question24">
        <input type="radio" name="q24" id="q24_button_1" value = "1"/>
		<label for="q24_button_1">1</label>
    </div>
    <div class="question24">
        <input type="radio" name="q24" id="q24_button_2" value = "2"/>
		<label for="q24_button_2">2</label>
    </div>
    <div class="question24">
        <input type="radio" name="q24" id="q24_button_3" checked="checked" value = "3"/>
		<label for="q24_button_3">3</label>
    </div>
	<div class="question24">
        <input type="radio" name="q24" id="q24_button_4" value = "4"/>
		<label for="q24_button_4">4</label>
    </div>
	<div class="question24">
        <input type="radio" name="q24" id="q24_button_5" value = "5"/>
		<label for="q24_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>Artistic</u></p>
    <div class="question25">
        <input type="radio" name="q25" id="q25_button_1" value = "1"/>
		<label for="q25_button_1">1</label>
    </div>
    <div class="question25">
        <input type="radio" name="q25" id="q25_button_2" value = "2"/>
		<label for="q25_button_2">2</label>
    </div>
    <div class="question25">
        <input type="radio" name="q25" id="q25_button_3" checked="checked" value = "3"/>
		<label for="q25_button_3">3</label>
    </div>
	<div class="question25">
        <input type="radio" name="q25" id="q25_button_4" value = "4"/>
		<label for="q25_button_4">4</label>
    </div>
	<div class="question25">
        <input type="radio" name="q25" id="q25_button_5" value = "5"/>
		<label for="q25_button_5">5</label>
    </div>
	</br>
	</br>
	<p><u>Decisive</u></p>
    <div class="question26">
        <input type="radio" name="q26" id="q26_button_1" value = "1"/>
		<label for="q26_button_1">1</label>
    </div>
    <div class="question26">
        <input type="radio" name="q26" id="q26_button_2" value = "2"/>
		<label for="q26_button_2">2</label>
    </div>
    <div class="question26">
        <input type="radio" name="q26" id="q26_button_3" checked="checked" value = "3"/>
		<label for="q26_button_26">3</label>
    </div>
	<div class="question26">
        <input type="radio" name="q26" id="q26_button_4" value = "4"/>
		<label for="q26_button_4">4</label>
    </div>
	<div class="question26">
        <input type="radio" name="q26" id="q26_button_5" value = "5"/>
		<label for="q26_button_5">5</label>
    </div>
	</br>
	</br>
	
	<?php print"<input type='Submit' value = 'Submit!' onClick = doMatch('$userid');>" ?>
	</form>	
</div>
<?php } ?>	
			
				</div><!-- #match -->
			</div><!-- #content -->
		</div><!-- #primary -->
		<img src="<?php bloginfo('stylesheet_directory'); ?>/match-trans.png" style="display: none;" /> 	
<?php 
	get_sidebar('empty');
	get_footer(); ?>